package me.chan.time;

import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.Period;
import java.time.temporal.ChronoUnit;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalAmount;
import java.time.temporal.TemporalField;

public class TimeInstant {

	public static void main(String... args) {
		Instant instant = Instant.ofEpochSecond(3);
		System.out.println(instant);
		//Unsupported field: DayOfMonth
		//int day = Instant.now().get(ChronoField.DAY_OF_MONTH);
		//System.out.println(day);
		
		Duration _3minutes = Duration.ofMinutes(3);
		System.out.println(_3minutes);
		
		Duration _3minute = Duration.of(3, ChronoUnit.MINUTES);
		System.out.println(_3minute);
		
		Period _10days = Period.ofDays(10);
		System.out.println(_10days);
		
		LocalDate date1 = LocalDate.now();
		LocalDate date2 = date1.withYear(2016);
		LocalDate date3 = date2.minusYears(4);
		LocalDate date4 = date3.plusMonths(5);
		LocalDate date5 = date4.minus(5, ChronoUnit.MONTHS);
		//2017-03-28 2016-03-28 2012-03-28 2012-08-28
		System.out.println(date1+" " + date2+" "+date3+" "+date4+" "+date5);
	}
}
